package com.learn.java3y.java.object;

import java.util.Objects;

public class Address {

    private String cityNo;
    private String streetNo;
    private String provinceNo;

    /**
     * 使用 IDEAL 默认的模板生成 equals 和 hashCode
     * @param o
     * @return
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Address)) return false;
        Address address = (Address) o;
        return cityNo.equals(address.cityNo) &&
                streetNo.equals(address.streetNo) &&
                provinceNo.equals(address.provinceNo);
    }

    @Override
    public int hashCode() {
        return Objects.hash(cityNo, streetNo, provinceNo);
    }

    public Address(String cityNo, String streetNo, String provinceNo) {
        this.cityNo = cityNo;
        this.streetNo = streetNo;
        this.provinceNo = provinceNo;
    }

    @Override
    public String toString() {
        return "Address{" +
                "cityNo='" + cityNo + '\'' +
                ", streetNo='" + streetNo + '\'' +
                ", provinceNo='" + provinceNo + '\'' +
                '}';
    }
}
